package com.wedo.mall.adapter;

import android.content.Context;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.e.library.activity.EActivity;
import com.e.library.adapter.Adapter;
import com.e.library.adapter.EAdapter;
import com.wedo.mall.R;
import com.wedo.mall.activity.user.EvaluateActivity;
import com.wedo.mall.entity.GoodsData;
import com.wedo.mall.entity.OrderData;
import com.wedo.mall.util.WUrl;
import com.wedo.mall.widget.GoodsListView;
import com.wedo.mall.widget.StarView;

import java.util.List;

/**
 * Created by Lawrence on 2017/11/9.
 */

public class OrderDetailAdapter extends Adapter<GoodsData> {
    //（0.待支付，1.待发货，2.待收货，3.待评价，4.已完成，5.作废，6.退换货）
    OrderData orderData;

    public OrderDetailAdapter(Context context, List<GoodsData> goodsDatas,OrderData orderData) {
        super(context, goodsDatas);
        this.orderData = orderData;
    }

    @Override
    protected int layout() {
        return R.layout.item_order_detail;
    }

    @Override
    protected void bind(EHolder holder, GoodsData goodsData, int position) {

        TextView tv_agent_name = holder.find(R.id.tv_agent_name);
        TextView tv_distance = holder.find(R.id.tv_distance);
        StarView sv_star = holder.find(R.id.sv_star);
        ImageView iv_logo = holder.find(R.id.iv_logo);
        GoodsListView glv_goods = holder.find(R.id.glv_goods);


        tv_agent_name.setText(goodsData.agent_name);
        Glide.with(mContext).load(WUrl.url(goodsData.logo)).error(R.drawable.place_holder_goods).placeholder(R.drawable.place_holder_goods).diskCacheStrategy(DiskCacheStrategy.ALL).into(iv_logo);
        sv_star.star(Integer.parseInt(goodsData.star));
        tv_distance.setText(goodsData.distance+"km");
        glv_goods.record(goodsData.goodsList,orderData,mContext);

    }
}
